<template>
    <TCollapse title="特别修正信息">
        <MyForm ref="formRef" v-model="queryParams" :form-option="formOption" />
        <div class="main-case" style="margin-top: 4px">
            <div class="case-title"><i style="color: red;">*</i> 特别修正原因：</div>
            <el-input :disabled="showOperate" type="textarea" v-model="afterModifyRemark"
                class="pms-textarea" :maxlength="250" :autosize="{ minRows: 5}"></el-input>
        </div>
    </TCollapse>
</template>

<script>
import MyForm from '@/components/basic/myForm'
import { Mixins } from "@/views/speciaCorrection/minix"
import {
    getSpecialDetail
} from "@/api/speciaCorrection/index"
export default {
    name: "SpecialCause",
    components: { MyForm },
    mixins: [Mixins],
    watch: {
        newPrjDetail: {
            handler(val) {
                if (JSON.stringify(val) !== '{}') {
                    this.getSpecialInfo()
                }
            },
            deep: true,
            immediate: true
        }
    },
    data() {
        return {
            afterModifyRemark: "",
            queryParams: {},
            formOption: {
                size: 'mini',
                inline: true,
                labelWidth: '160px',
                itemData: [
                    {
                        type: 'input',
                        prop: 'appPersonName',
                        value: '',
                        width: '',
                        colSpan: 6,
                        disabled: true,
                        clearable: true,
                        label: '特别修正申请人：'
                    },
                    {
                        type: 'input',
                        prop: 'appDate',
                        value: '',
                        width: '',
                        disabled: true,
                        colSpan: 6,
                        clearable: true,
                        label: '特别修正申请时间：'
                    },
                ]
            }
        }
    },
    computed: {
        showOperate() {
            return this.newWorkDetail.activityDefID !== 'correct_01'
        }
    },
    methods: {
        async getSpecialInfo() {
            const params = {
                prjId: "",
                adjustId: this.newWorkDetail?.bizObject?.bizSeq || this.$route.query.adjustId,
            }
            const { code, data } = await getSpecialDetail(params)
            if (+code === 200) {
                this.queryParams = data
                this.afterModifyRemark = data.afterModifyRemark || ''
            }
        },
        validateInput(str) {
            const regex = /^(?!(?:[a-zA-Z]+|\d+)$)[\s\S]+$/;
            return regex.test(str);
        },
        submit() {
            let message = ''
            let _code = 200
            if (!this.validateInput(this.afterModifyRemark)) {
                _code = 500
                message = this.afterModifyRemark === '' ? "请填写特别修正原因" : "【特别修正原因】不能为纯英文或者纯数字!"
            }
            return {
                code: _code,
                message: message
            }
        },
    },
}

</script>
<style lang="scss" scoped>
.main-case {
    display: flex;
    justify-content: space-between;
    align-items: center;

    .case-title {
        color: #606266;
        min-width: 159px;
        text-align: center;
        padding-left: 48px;
    }
}
::v-deep .el-textarea.is-disabled .el-textarea__inner{
    background-color: #f7f7f7;
    color:#424242 ;
}
</style>